/*********************
* Author:Dzlua
* QQ:505544956
* time:2016/07/31
*/
#ifndef __EDUI_SDL_RENDER_H__
#define __EDUI_SDL_RENDER_H__

#include "SDL.h"
#include "SDL_ttf.h"
#include "edui/interface/IRender.h"

EDUI_NAMESPACE_BEGIN

class Render : public IRender
{
public:
    Render();
    ~Render();
public:
    virtual bool Create(IWindow* wnd, int index = -1, RendererFlags flags = RENDERER_ACCELERATED);
	virtual bool IsOK();
	virtual void Destroy();
	virtual Size GetSize();

    virtual void Clear(const Color* color = 0);
	virtual void Present(const Rect* rc);

	virtual bool SetTarget(ITexture* texture);
	virtual ITexture* GetTarget();

	virtual bool SetBlendMode(BlendMode mode);
	virtual BlendMode GetBlendMode();

	virtual bool SetColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
    virtual bool SetColor(const Color* color);
    virtual Color GetColor();

	virtual bool SetScale(float scaleX, float scaleY);
	virtual PointF GetScale();

	virtual bool SetClip(const Rect *rect);
	virtual Rect GetClip();
	virtual bool IsClipEnabled();

	virtual bool SetViewport(const Rect *rect);
	virtual Rect GetViewport();

	virtual void DrawPoint(int x, int y);
	virtual void DrawLine(int x1, int y1, int x2, int y2);
	virtual void DrawRect(const Rect * rect);
	virtual void DrawRect(int x1, int y1, int x2, int y2);
	virtual void FillRect(const Rect * rect);
	virtual void FillRect(int x1, int y1, int x2, int y2);

	virtual void DrawTexture(ITexture* img, const Rect* src, const Rect* dst, int id = 0);
	virtual void DrawTexture(ITexture* img, int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2, int id = 0);
	virtual void DrawScaleTexture(ITexture* img, const Rect* src, const Rect* dst, const Rect1* corner, bool bHole = false, int id = 0);
	virtual void DrawMaskTexture(ISurface* img, ISurface* mask, const Rect* src, const Rect* dst, int id = 0);

	virtual void DrawText(const char* text, const Rect* rc, IFont* font, const Color* fg = 0);
	virtual void DrawText(const char* text, int x, int y, IFont* font, const Color* fg = 0);
	virtual void DrawWrappedText(const char* text, const Rect* rc, IFont* font, const Color* fg = 0);

	virtual IWindow* GetWindow();
public:
	SDL_Renderer* GetSDLRender() const;
    static Render* ToRender(IRender * render);
protected:
    SDL_Renderer* m_render;
	SDL_Texture* m_texture;
	IWindow* m_wnd;
};

EDUI_NAMESPACE_END

#endif